﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PotatoSoft.ViewModel;

namespace PotatoSoft.CustomControl
{
    /// <summary>
    /// Interaction logic for ImageControl.xaml
    /// </summary>
    public partial class ImageControl : UserControl
    {
        public ImageControl(ImageControlViewModel imageControlVM)
        {
            InitializeComponent();

            Binding commandBinding = new Binding(ImageControlViewModel.PotatoImageSourcePropertyName);
            commandBinding.Mode = BindingMode.TwoWay;
            commandBinding.Source = imageControlVM.PotatoImageSource;
            ImageBox.SetBinding(Image.SourceProperty, commandBinding);

            commandBinding = new Binding(ImageControlViewModel.PotatoImageWidthPropertyName);
            commandBinding.Mode = BindingMode.TwoWay;
            commandBinding.Source = imageControlVM.PotatoImageWidth;
            ImageBox.SetBinding(Image.WidthProperty, commandBinding);

            commandBinding = new Binding(ImageControlViewModel.PotatoImageHeightPropertyName);
            commandBinding.Mode = BindingMode.TwoWay;
            commandBinding.Source = imageControlVM.PotatoImageHeight;
            ImageBox.SetBinding(Image.HeightProperty, commandBinding);
        }
    }
}
